<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>

    <input type="text" class="user">
    <br>
    <input type="password" class="pwd">
    <br>
    <button>注册</button>

    <script src="../js/ajax.js"></script>

    <script>

        const oBtn = document.querySelector('button') ;
        const oUser = document.querySelector('.user') ;
        const oPwd = document.querySelector('.pwd') ;

        oBtn.onclick = function() {
            const username = oUser.value ;
            const userpwd = oPwd.value ;

            if(username && userpwd) {

                // 判断
                const oA = document.querySelector('#a') ;
                if(oA) {
                    oA.remove() ;
                }


                //   创建一个script
                const oScript = document.createElement('script') ;
                oScript.id = 'a' ;
                oScript.src = 'http://192.168.20.59/wh2209/day27/%E8%AF%BE%E5%A0%82%E4%BB%A3%E7%A0%81/php/reg_jsonp.php?username=' + username + '&userpwd=' + userpwd;
                document.body.appendChild(oScript) ;
            }
        }



        function callback(data) {
            console.log(data);
        }

        

    </script>
    
</body>
</html>